package com.slz3.business.module.systemManagement.sysUser.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.google.gson.annotations.Expose;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import com.slz3.business.module.systemManagement.sysRole.domain.SysRoleEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import static javax.persistence.EnumType.STRING;

@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
@JsonIgnoreProperties(value = "serPass", allowSetters = true, allowGetters = false)
public class SysUserEntity extends DomainEntity {

    /**
     * 编号
     */
    @Column(length = 80)
    //@NotNull(message = "serNum 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 80, message = "ser2 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serNum;

    /**
     * 备注
     */
    @Basic(fetch = FetchType.LAZY)
    @Type(type = "text")
    private String serMemo;

    /**
     * 审核状态
     */
    @Enumerated(STRING)
    // @NotNull(message = "serAudit 必须非空!", groups = {Add.class, Modify.class})
    private AuditFlag serAudit;

    /**
     * 启用状态
     */
    @Enumerated(STRING)
    // @NotNull(message = "serUsing 必须非空!", groups = {Add.class, Modify.class})
    private UsingFlag serUsing;

    /**
     * 标签
     */
    private String serLabels;

    private String serCode;

    //  @NotNull(message = "{TT.ZMD.SysBasicUser.serType}必填", groups = {Add.class, Modify.class})
    // @Size(min = 1, max = 90, message = "{TT.ZMD.SysBasicUser.serType}长度长度必须大于 1 小于 90 个字符", groups = {Add.class, Modify.class})
    private String serTypeCeofNum;

    private String serStatus;

    // @NotNull(message = "{TT.ZMD.SysBasicUser.serName}必填", groups = {Add.class, Modify.class})
    //@Size(min = 1, max = 90, message = "{TT.ZMD.SysBasicUser.serName}长度长度必须大于 1 小于 90 个字符", groups = {Add.class, Modify.class})
    private String serName;

    private String serAccounts;

    // @NotNull(message = "{TT.ZMD.SysBasicUser.serUser}必填", groups = {Add.class, Modify.class, Login.class})
    //@Size(min = 1, max = 90, message = "{TT.ZMD.SysBasicUser.serUser}长度长度必须大于 1 小于 90 个字符", groups = {Add.class, Modify.class, Login.class})
    private String serUser;

    // @NotNull(message = "{TT.ZMD.SysBasicUser.serPass}必填", groups = {Add.class, Login.class})
    //@Pattern(regexp="^(?![0-9]+$)(?![a-zA-Z]+$)[_0-9A-Za-z]{6,15}$", message="密码必须是6~15位数字和字母的组合", groups = {Add.class})
    @NotNull(message = "Please provide a valid password", groups = {Add.class, Modify.class})
    private String serPass;

    //@NotNull(message = "{TT.ZMD.SysBasicUser.serEmail}必填", groups = {Add.class, Modify.class})
    // @Size(min = 1, max = 90, message = "{TT.ZMD.SysBasicUser.serEmail}长度长度必须大于 1 小于 90 个字符", groups = {Add.class, Modify.class})
    @Email(message = "Please provide a valid email address", groups = {Add.class, Modify.class})
    private String serEmail;

    private String serPhoneAreaCode;

    //  @NotNull(message = "{TT.ZMD.SysBasicUser.serPhone}必填", groups = {Add.class, Modify.class})
    // @Pattern(regexp="^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$", message="手机号格式不正确", groups = {Add.class, Modify.class})
    private String serPhone;

    @NotNull(message = "Please provide a valid organize", groups = {Add.class, Modify.class})
    private UUID organizeUuid;

    // 加盐uuid
    @JsonIgnore
    private UUID saltUuid;

}
